package cc.rengu.redp.common.domain;

import java.util.HashMap;

/**
 * 前端应答标准范式
 */
public class RedpResponse extends HashMap<String, Object> {

    private static final long serialVersionUID = -8713837118340960775L;

    /**
     * 应答消息
     * @param message
     * @return
     */
    public RedpResponse message(String message) {
        this.put("message", message);
        return this;
    }

    /**
     * 返回数据
     * @param data
     * @return
     */
    public RedpResponse data(Object data) {
        this.put("data", data);
        return this;
    }

    /**
     * 标准应答状态-成功
     * @return
     */
    public RedpResponse success(){
        this.put("status", true);
        return this;
    }

    /**
     * 标准应答状态-失败
     * @return
     */
    public RedpResponse failure(){
        this.put("status", false);
        return this;
    }

    /**
     * 其它应答状态
     * @param status
     * @return
     */
    public RedpResponse status(String status){
        this.put("status", status);
        return this;
    }

    @Override
    public RedpResponse put(String key, Object value) {
        super.put(key, value);
        return this;
    }

    public static RedpResponse getInstance() {
        return new RedpResponse();
    }
}
